#!/bin/bash

localpath=`readlink -f $(dirname $0)`
cd $localpath

function pathnametransfor(){
	echo $1 | sed 's/\//./g'
}

function checklogdir(){
	if [ ! -d ./log ];then
	   mkdir ./log
        fi
}

function getrealpath(){
      readlink -f $1
}

function runbatch(){
   START_TIME=$(date +'%Y-%m-%d %H:%M:%S')
   LOG_TIME=$(date +'%Y%m%d%H%M%S')
   nohup java -jar st-history.jar -d $1 -i zhsg.shantui.com -p 9999 2>&1 > ./log/history$(pathnametransfor $1)-${LOG_TIME}.log && echo "path $1 run time: $START_TIME --> $(date +'%Y-%m-%d %H:%M:%S')" | tee -a run_time.txt &
}

function calc_current_running(){
   ps -ef | grep st-history.jar | wc -l
}
#echo $(getrealpath $1)
checklogdir
runbatch $(getrealpath $1)
exit 0
